﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.users
{
    public partial class userlinks : BasePage
    {
        lcmyjobs.BLL.user_basic bub = new BLL.user_basic();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Title = string.Format("个人管理中心—安全保密设置：联系方式保密   {0}", Application["webname"].ToString());
                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    this.lblName.Text = Session["user_name"].ToString();
                    show(id, true);

                }
                else
                {
                    Response.Redirect("userlogin.html");
                }
            }

        }
        protected void show(int id, bool text)
        {
            int i = bub.Getuserlink(id);
            if (i == 1)
            {
                this.Label1.Text = "公开";
                if (text)
                {
                    rbt1.Checked = true;
                    rbt0.Checked = false;
                }
            }
            else
            {
                if (text)
                {

                    rbt0.Checked = true;
                    rbt1.Checked = false;
                }
                Label1.Text = "不公开";
            }
        }


        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                int i = 0;
                if (rbt1.Checked) i = 1;
                int r = bub.changelink(id, i);
                if (r != 0)
                {
                    Maticsoft.Common.MessageBox.Show(this, "修改成功！");
                    show(id, false);
                }
                else
                    Maticsoft.Common.MessageBox.Show(this, "修改失败！");

            }
            else
            {
                Response.Redirect("userlogin.html");
            }


        }
    }
}